<?php
/*
	提现
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
defined('BY_JYA') or exit('error');
global $_RQ;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'get';
$return['ischecklogin']=cfc('core')->checklogin('','',true);
$credit_types=credit_types(true);
if($_RQ['op']=='get'){
	$member=$this->get('member',array('mid'=>$_SESSION['uid']));
	$basic=model('core/member')->basic($_SESSION['uid']);
	$member=array_merge($member,$basic);
	$return['member']=$member;
	$return['params']['type']=$_RQ['type']?:3;
	$return['allmoney']=$member['gongb'];
	$return['typetitle']='月供标';
	$return['is_open']=$tixianset['is_open'];
	$return['open_upbaofee']=$tixianset['open_upbaofee'];
	$return['post']=array('type'=>$return['params']['type']);
	set_html('title','我的月供标');
	exi($return);
}
if($_RQ['op']=='list'){
	$pindex = max(1, intval($_RQ['page']));
	$psize = 15;
	$params=array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']);
	if($_RQ['isadd']){
		$params['isadd']=intval($_RQ['isadd']);
	}
    $orderby='createtime desc';
	$total='';
	$list=pdo_getslice('jy_carfee_gongblog',$params,array($pindex,$psize),$total,'','','id desc');
	if($list){
		foreach($list as &$item){
			$item['createtime']=date('Y/m/d H:i:s',$item['createtime']);
			$item['is_addtitle']=$item['isadd']?'获得':'消费';
			$item['typetitle']=$credit_types[$item['type']];
			$item['statustitle']=$this->cheblog_status[$item['status']];
		}
	}
	$return['list']=$list;
	exi($return);
}
if($_RQ['op']=='zhuan'){
	$post=get_postdata();
	$member=$this->get('member',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']));
	if(!$post['fee']){
		exi('请输入转让个数！','erroe');
	}
	if($post['fee']<=0){
		exi('请输入正确的转让个数！','erroe');
	}
	if(!$post['tomid']){
		exi('请输入接收人MID(邀请码)！','erroe');
	}
	if($member['gongb']<=3){
		exi('月供标五年内不满3个不能转让','erroe');
	}
	if($member['gongb']<$post['fee']){
		exi('转让额度不能大于，当前剩余额度！','erroe');
	}
	if($member['gongb']-$post['fee']<3){
		exi('剩余月供标不能小于3个！','erroe');
	}
	$tomember=$this->get('member',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$post['tomid']));
	$tomid=$tomember['mid'];
	if(!$tomid){
		exi('没找到接收人，转让失败！','erroe');
	}
	$this->update('member',array('gongb -='=>$post['fee']),array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']));
	$newpost=array(
		'mid'=>$_SESSION['uid'],
		'tomid'=>$post['tomid'],
		'fee'=>$post['fee'],
	);
	$this->model('model')->addgongblog($newpost,0,'转让给别人');
	//$this->update('member',array('gongb +='=>$post['fee']),array('uniacid'=>$_SESSION['uniacid'],'mid'=>$post['tomid']));
	//$newpost['mid']=$post['tomid'];
	//$this->model('model')->addgongblog($newpost,1,'别人转让的');
	exi('转让成功！等待审核');
}